﻿using System;
using System.Collections.Generic;
using System.Text;

using DataAccess;
using RichPlugins;
using Common;
using BusinessLogic.BusinessRules;
using BusinessLogic.ClassFactory;

namespace IssueCommon
{
    public class ReplaceWPlugin
    {
        //处理站点插件数据
        public static string ReplaceWebSitePlugin(Plugin objPlugin, SessionUser _sessionUser)
        {
            string strXml = string.Empty;
            string strWSID = objPlugin.GetValueByTagName("id");
            int intWSID = 0;
            if (strWSID == string.Empty)
            {
                intWSID = _sessionUser.WebSiteID;
            }
            else
            {
                intWSID = int.Parse(strWSID);
            }
            WebSiteFactory objFactory = new WebSiteFactory();
            WebSite objWebSite = objFactory.Creator(intWSID);
            if (objWebSite == null)
            {
                string strMsg = string.Format("解析站点插件出错！找不到ID={0}的站点！", intWSID);
                throw new CustomException(strMsg);
            }
            else
            {
                strXml = objWebSite.GetWebSiteXml();
            }
            objFactory.Dispose();
            return strXml;
        }
    }
}
